package com.bimowo.search.controller;

import com.bimowo.search.model.Information;
import com.bimowo.search.service.SearchService;
;

import java.util.List;
import java.util.Map;

//@RestController
@Controller
public class SearchController {
    @Autowired
    SearchService searchService;

    @RequestMapping("/api/search")
    @ResponseBody
    public List<Information> search(String word){
        return searchService.search(word);
    }
    @RequestMapping("/page/search")
    public String searchIndexPage(String word, Model m){
        m.addAttribute("word",word);
        m.addAttribute("list",searchService.search(word));
        return "search";
    }


    @RequestMapping("/api/rank")
    @ResponseBody
    public List<Map<String,Object>> searchRank(){
        return searchService.searchRank();
    }
    @RequestMapping("/pade/rank")
    public String seachRankPage(Model  m){
        m.addAttribute("list",searchService.searchRank());
        return "rank";
    }

}
